package restaurant;

/**
 * Manager class contains the user interface between the user and the
 * functionality of the application as well as controlling all functionality.
 * 
 * @author CT267, SG350, MSM41.
 */
public class Manager {

	/**
	 * Field variables.
	 */
	private Items items = null;
	private Orders orders = null;
	private IOsystem io = null;
	private Reports reports = null;

	/**
	 * Constructor creates, Items and Orders class objects and makes use of
	 * their features as well as, forwarding these onto Report class for further
	 * analytical use.
	 */
	public Manager() {
		items = new Items();
		orders = new Orders(items.getMenuTreeSet());
		reports = new Reports(orders.getOrderList(), items.getMenuTreeSet());
	}

	/**
	 * Run initialises the application.
	 */
	public void run() {
		items.getMenuItems();
		orders.treeMapForTableSummary();
		orders.getTableSummary();
		orders.getIndividualTableSummary(1);
		reports.getDishesNotOrdered();
		reports.getFrequecyReport();
	}

	/**
	 * Populate GUI with FULL table information.
	 * 
	 * @return String
	 */
	public String GUISummary() {
		return orders.getTableSummary();
	}
	
	/**
	 * Populate GUI with SINGLE table information.
	 * 
	 * @return String
	 */
	public String GUISelectedSummary(int tableID) {
		orders.treeMapForTableSummary();
		return orders.getIndividualTableSummary(tableID);
	}

	/**
	 * Populate GUI with frequency data.
	 * 
	 * @return String
	 */
	public String GUIFrequency() {
		return reports.getFrequecyReport();
	}

	

	/**
	 * Populate GUI with non ordered food.
	 * 
	 * @return String
	 */
	public String GUINotOrderd() {
		return reports.getDishesNotOrdered();
	}

	/**
	 * Save writes report to file.
	 */
	public void save() {
		io = new IOsystem();

		String output = items.getMenuItems() + "\n\n"
				+ orders.getTableSummary() + "\n\n"
				+ reports.getFrequecyReport() + "\n\n"
				+ reports.getDishesNotOrdered();

		io.saveFile(output, "report.txt");
	}
}
